﻿//刘伟
//Cookie操作类
//2008-05-22  
 
//保存Cookie,后面输入分钟
function saveCookie(name, value, mins)
{
    var expire = "";
    if(mins != null)
    {
        expire = new Date((new Date()).getTime() + parseInt(mins) * 3600000);
        expire = "; expires=" + expire.toGMTString();
    }
    document.cookie = name  + "=" + escape(value) + expire+";path=/;";
}

//读Cookie值
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
      offset = document.cookie.indexOf(search);
      if (offset != -1)
      { 
        offset += search.length;
        end = document.cookie.indexOf(";", offset);
        if (end == -1) end = document.cookie.length;
        cookieValue = unescape(document.cookie.substring(offset, end));
      }
  }
  return cookieValue;
 }
 
 //删除Cookie
function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 10);
    var cval="";
    document.cookie= name + "="+cval+";expires="+exp.toGMTString()+";path=/;";
}